#include <iostream> 
#include <assert.h>
#include <pthread.h>
#include <string>

namespace cache
{
    enum
    {
        HEAD_SIZE = 32  //the size of liner table
    };
    class CCacheData
    {
    public:
        CCacheData():m_data_1(0), m_data_2(0)
        {
        }
        int m_data_1;
        double m_data_2;
        std::string m_data_3;
    };
    class SNode
    {
    public:
        CCacheData *m_pData;
        SNode *m_pNext;
        pthread_t m_nTid;
        int m_iStoryTimes;
    public:
        SNode()
        {
            m_pData = new CCacheData;
            m_pNext = NULL;                                     
            m_nTid = 0;
        }
        ~SNode()
        {                  
            if( NULL != m_pData )
                delete m_pData;
        }
    };

    class CThreadVariable :public SNode
    {
    private:
        SNode *m_pNode;
        pthread_mutex_t m_mutex;
    public:
        CThreadVariable();
        ~CThreadVariable();
    public:
        SNode *get_var();
        SNode *get_var(pthread_t nTid);
        inline SNode *get_SNodeAddress()
        {
            return m_pNode;
        }
    private:
        // Hash diverge branch
        SNode *insert(SNode *pHead);
    };
}